package com.qianji.service.impl;

import cn.hutool.core.date.DateTime;
import com.qianji.mapper.ConsequenceMapper;
import com.qianji.pojo.ConsequenceDto;
import com.qianji.service.ConsequenceService;
import com.qianji.utils.Result;
import com.qianji.vo.ConsequenceAddVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by 阳家桂 on 2021/3/12 15:38
 */
@Service
public class ConsequenceServiceImpl implements ConsequenceService {
    @Autowired
    private ConsequenceMapper consequenceMapper;

    /**
     * 查询抽奖结果
     * @param consequenceDto
     * @return
     */
    @Override
    public Result selectCon(ConsequenceDto consequenceDto) {
        consequenceDto.setCreateTime(new DateTime());
        //consequenceDto.setPage((consequenceDto.getPage() - 1) * consequenceDto.getLimit());
        List<ConsequenceDto> conList = consequenceMapper.selectCon(consequenceDto);
        //Long count = consequenceMapper.count(consequenceDto);
        return Result.success(conList);
    }


    /**
     * 添加抽奖结果
     * @param consequenceAddVO
     * @return
     */
    @Override
    public Integer addCon(ConsequenceAddVO consequenceAddVO) {
        consequenceAddVO.setCreateTime(new DateTime());
        return consequenceMapper.addCon(consequenceAddVO);
    }


    /**
     * 删除抽奖结果
     * @param id
     * @return
     */
    @Override
    public Integer deleteCon(String id) {
        return consequenceMapper.deleteCon(id);
    }

    @Override
    public Integer getPrize(Long id) {

        return consequenceMapper.getPrize(id);
    }
}
